API

  • Capabilities:
    • Get Pose:
      • Body
      • Flashlight Head
      • Beacons
    • Set Target Position:
      • Flashlight Head
    • Set Joint Velocity:
      • Drivetrain
    • Get Image
      • line scan camera

In [2]:
import vrep

In [3]:
clientID=vrep.simxStart('127.0.0.1',19997,True,True,5000,5)
clientID


Out[3]:
0

In [4]:
res,objs=vrep.simxGetObjects(clientID,
                             vrep.sim_handle_all,
                             vrep.simx_opmode_oneshot_wait)
# res, objs

Line scan camera


In [5]:
errcode, handle = vrep.simxGetObjectHandle(clientID,
                                           'Vision_sensor',
                                           vrep.simx_opmode_oneshot_wait)
handle


Out[5]:
0

In [6]:
%%timeit
errorcode, res, image = vrep.simxGetVisionSensorImage(clientID,
                              handle,
                              0,
                              vrep.simx_opmode_streaming)


100000 loops, best of 3: 5.27 µs per loop

Object Position


In [7]:
%%timeit
ec, pos = vrep.simxGetObjectPosition(clientID, handle, -1, vrep.simx_opmode_streaming)


100000 loops, best of 3: 5.04 µs per loop

Object Orientation


In [12]:
%%timeit
ec, orientation = vrep.simxGetObjectOrientation(clientID, handle, -1, vrep.simx_opmode_streaming)


100000 loops, best of 3: 5.15 µs per loop

In [15]:
ec, orientation = vrep.simxGetObjectOrientation(clientID, handle, -1, vrep.simx_opmode_streaming)

In [16]:
orientation


Out[16]:
[3.1028072834014893, 0.5005983710289001, -1.490120530128479]

Set Joint Position


In [19]:
errcode, handle = vrep.simxGetObjectHandle(clientID,
                                           'Neck',
                                           vrep.simx_opmode_oneshot_wait)
handle


Out[19]:
15

In [22]:
import math

In [25]:
vrep.simxSetJointTargetPosition(clientID,
                                handle,
                                -math.pi/2,
                                vrep.simx_opmode_streaming)


Out[25]:
0

Set Joint Velocity


In [1]:
errcode, handle = vrep.simxGetObjectHandle(clientID,
                                           'leftMotor0',
                                           vrep.simx_opmode_oneshot_wait)
handle


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-e496fca19d0c> in <module>()
----> 1 errcode, handle = vrep.simxGetObjectHandle(clientID,
      2                                            'leftMotor0',
      3                                            vrep.simx_opmode_oneshot_wait)
      4 handle

NameError: name 'vrep' is not defined

In [48]:
vrep.simxSetJointTargetVelocity(clientID,
                                handle,
                                0,
                                vrep.simx_opmode_oneshot)


Out[48]:
0

In [ ]: